package useFn;

public class demo6shouhuxiancheng {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);

                }
            }
        }, "线程A:");
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);

                }
            }
        }, "线程B:");
        t1.start();
        t2.start();
        t2.setDaemon(true);// 线程1结束的时候, 线程2 就跟着死了. (守护天使)
    }
}
